package com.example.permissionsystem1_1.system.config;

import com.example.permissionsystem1_1.system.filter.AuthAndFunctionFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 用于将一些特定功能的类在spring中进行注册和配置
 */
@Configuration
public class SpringComponentBeanConfig {
    //对AuthAndFunctionFilter过滤器进行注册和配置
    @Bean
    public FilterRegistrationBean<AuthAndFunctionFilter> RegistAuthAndFunctionFilter(){
        //通过FilterRegistrationBean实例设置优先级可以生效
        //通过@WebFilter无效
        FilterRegistrationBean<AuthAndFunctionFilter> bean = new FilterRegistrationBean<AuthAndFunctionFilter>();
        bean.setFilter(new AuthAndFunctionFilter());//注册自定义过滤器
        bean.setName("AuthAndFunctionFilter");//过滤器名称
        bean.addUrlPatterns("/*");//过滤所有路径
        bean.setOrder(6);//优先级，最顶级
        return bean;
    }


}
